<{include file='../common/head.tpl'}>
<script language="javascript">
<{if $tips}>
var msg = '<{$tips}>';
//$(window).bind('beforeunload',function(e){
//    e = e || window.event;
///    if (e) {
//        e.returnValue = msg;
//    }
//    return  '以下网点问卷未提交，请提交后离开\n'+msg;
//});
<{/if}>

</script>
<!--header End-->
<div class="main w1060">
        <{if $level!=4}>
            <div class="dbserch">
                    <form action="/benchmark/index" method="get">
                        <!--<select class="u185_input" name="level" autocomplete="off">
                            <option value="0">所有</option>
                            <{foreach $level_list as $key => $val}>
                            <{if $key!=5}>
                            <option value="<{$key}>" <{if $current_level==$key}>selected="selected"<{/if}>><{$val.desc}></option>
                            <{/if}>
                            <{/foreach}>
                        </select>-->

                        <select id="u185_input" name="project_question_id" autocomplete='false'>
                            <option value='0'>请选择项目问卷</option>
                            <{foreach $project_list as $key => $val}>
                            <option value="<{$val.project_id}>" disabled="disabled" ><b><{$val.project_name}></b></option>
                            <{if isset($project_question[$val.project_id])}>
                            <{foreach $project_question[$val.project_id] as $k => $v}>
                            <option value="<{$val.project_id}>-<{$v.question_id}>" <{if $question_id==$v.question_id}>selected="selected"<{/if}>>----<{$v.question_name}></option>
                            <{/foreach}>
                            <{/if}>
                            <{/foreach}>
                        </select>
                        <select name="audit" class="u185_input" autocomplete="off">
                            <option value="-1">审核状态</option>
                            <{foreach $audit as $key => $val}>
                            <option value="<{$key}>" <{if $search_audit==$key}>selected="selected"<{/if}>><{$val}></option>
                            <{/foreach}>
                        </select>
                            <input name="" type="submit" value="确定"  class="anbut" />

                            <{if $level==1}><a href="/benchmark/all" target="_blank">查看所有网点对标数据</a><{/if}>
                    </form>
            </div>
        <{/if}>
                <form name="form2" method="post" id="myForm1" action="/benchmark/setaudit">
		<div class="biaoge">   
			<table width="100%" border="0" cellspacing="0">
			  <tr>
                              <td class="btzong3"><input type="checkbox" id="che_box" value="checkbox"></td>
                              <td class="btzong3">序号</td>
                              <td class="btzong3"><strong>网点名称</strong></td>
                              <td class="btzong3"><strong>项目名称</strong></td>
                            <td class="btzong3"><strong>问卷名称</strong></td>
				<td class="btzong3"><strong>审核状态</strong></td>
                                <td class="btzong3"><strong>当前结点</strong></td>
				<td class="btzong3"><strong>得分</strong></td>
				<td class="btzong3"><strong>操作</strong></td>
			  </tr>
                          <{foreach $netquestion as $key => $val}>
                          <{if $level==4&&($network_id==$val.network_id)}>
			  <tr>
                              <td>
                                  <{if $val.audit==0}>
                                  <input type="checkbox" name="nq_id[]" value="<{$val.nq_id}>" class="subcheck" <{if $val.status==2}>disabled="disabled"<{/if}>>
                                  <{/if}>
                              </td>
                              <td><{$val.network_id}></td>
                              <td><{$val.network_name}></td>
                              <td><{$project_list[$val.project_id].project_name}></td>
				 <td><{$question_list[$val.question_id].question_name}></td>
				<td>
                                    <{if $audit_show[$val.audit]}>
                                    <a href="javascript:;" onclick="detail(<{$val.nq_id}>);" title="点击查看详细审核记录">
                                        <{$audit_show[$val.audit]}>
                                    </a>
                                    <{/if}>
                                </td>
                                <td><{if isset($level_list[$val.node_id])}><{$level_list[$val.node_id].desc}><{else}>网点<{/if}></td>
				<td><{if $question_list[$val.question_id].show_score}><{$val.score|cut_number}><{else}>
                                    -.-
                                    <{/if}></td>
                                <td>
                                    <a href="javascript:;" onclick="window.open('/benchmark/view?nq_id=<{$val.nq_id}>')"><{if $val.op_node_id!=0}>浏览问卷<{else}>审核问卷<{/if}></a> 
			  </tr>
                          <{/if}>
                          <{if $level!=4}>
                          <tr id="show_complete_<{$val.nq_id}>">
                              <td>
                                  <input type="checkbox" name="nq_id[]" value="<{$val.nq_id}>" class="subcheck" <{if $val.status==2}>disabled="disabled"<{/if}>>
                              </td>
                              <td><{$val.network_id}></td>
                              <td><{$val.network_name}></td>
                              <td><{$project_list[$val.project_id].project_name}></td>
				<td><{$question_list[$val.question_id].question_name}></td>
				<td>
                                    <{if $level_list[$val.op_node_id]}><{$level_list[$val.op_node_id].desc}><{/if}>
                                    <{if $audit_show[$val.audit]}>
                                    <a href="javascript:;" onclick="detail(<{$val.nq_id}>);" title="点击查看详细审核记录"><{$audit_show[$val.audit]}></a>
                                    <{/if}>
                                </td>
                                <td><{if isset($level_list[$val.node_id])}><{$level_list[$val.node_id].desc}><{else}>网点<{/if}></td>
				<td><{if $question_list[$val.question_id].show_score}><{$val.score|cut_number}><{else}>
                                    -.-
                                    <{/if}></td>
                                <td><a href="javascript:;" onclick="window.open('/benchmark/view?nq_id=<{$val.nq_id}>')">浏览问卷</a><!-- <{if $level<4&&$val.status!=2}><span id='show_complete_<{$val.nq_id}>'> | <a href="javascript:;" onclick="complete(<{$val.nq_id}>);">完成</a></span><{/if}>--></td>
			  </tr>
                          <{/if}>
                          <{/foreach}>
			  
		  </table>
		</div>
		<div id="pages">
			<{$page}>
		</div>
		<div class="fudong">
                    <{foreach $level_auth as $key => $val}>
                    <{if $level==4}>
                    <input type="hidden" name="audit" value="<{$val}>" /><br/>
                    <{else}>
                    <input type="radio" name='audit' value='<{$val}>'><{$audit[$val]}><br/>
                    <{/if}>
                    <{/foreach}>
                    <input type="submit" value="提交" class="button"/>
		</div>
                </form>
</div>
<script type="text/javascript">
$(function(){
        var options = {         
        beforeSubmit:  showRequest,  
        success:       showResponse,
        dataType:  'json'
    }
    $('#myForm1').ajaxForm(options); 
    
    //判断subcheck的长度，如果没有的话，直接把提交按钮隐藏
    if ($('.subcheck').length==0){
        $('.fudong').remove();
    }
})
function showRequest(formData, jqForm, options) { 
    return true;
}
function showResponse(responseText, statusText, xhr, $form)  { 
    alert(responseText.note);
    window.location.reload();
}
 
//复选框事件  
//全选、取消全选的事件  
$(document).on("click","#che_box",function(){
    var ischecked= $("#che_box:checked").length;
 
    var $checkboxs =$("input[name='nq_id[]']");
    if(ischecked){
        $checkboxs.prop("checked",true);
    }else{
        $checkboxs.prop("checked",false);
    }
});

//设置问卷完成状态
function complete(nq_id){
    if (confirm('确认提交完成此问卷?')) {
        $.getJSON('/benchmark/SetStatus',{nq_id:nq_id,status:2},function(res){
            alert(res.note);
            if (res.status==1) {
                $('#show_complete_'+nq_id).remove();
            }
        });
    }

}
//详细审核历史记录
function detail(nq_id){
    $.layer({
        type: 2, 
        title: '网点审核历史记录',
        border:[10, 0.3, '#000'],
        closeBtn:[0, true],
        shade: [0.5, '#000'],
        offset: ['100px', ''],
        area: ['500px', '450px'],
        iframe: {src: '/benchmark/AuditHistory?nq_id='+nq_id}
    });
}
</script>
<!--main End-->
<{include file="../common/footer.tpl"}>
